package com.yukh.test.spring.aop.demo2;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class MyInterceptor implements MethodInterceptor {
//	private final Log logger = LogFactory.getLog(getClass());

	public Object invoke(MethodInvocation methodInvocation) throws Throwable {
		System.out.println("Beginning method (1): "
				+ methodInvocation.getMethod().getDeclaringClass() + "."
				+ methodInvocation.getMethod().getName() + "()");
		long startTime = System.currentTimeMillis();
		try {
			// TO hello
			Object result = methodInvocation.proceed();
			return result;
		} finally {
			System.out.println("Ending method (1): "
					+ methodInvocation.getMethod().getDeclaringClass() + "."
					+ methodInvocation.getMethod().getName() + "()");
			System.out.println("Method invocation time (1): "
					+ (System.currentTimeMillis() - startTime) + " ms.");
		}
	}
}